<!--
 * @Author: 雷宇航
 * @Date: 2021-07-28 13:53:46
 * @LastEditTime: 2021-07-29 14:07:27
 * @LastEditors: 雷宇航
 * @Description: 
 * @FilePath: \icm-vue\src\views\hifar\postsale\PostSaleQuestionItemList.vue
-->
<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="客户简称">
              <a-input placeholder="请输入客户简称" v-model="queryParam.customerShortName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="项目名称">
              <a-input placeholder="请输入项目名称" v-model="queryParam.projectName"></a-input>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="问题类型">
                <j-dict-select-tag
                  v-model="queryParam.questionType"
                  dictCode="icm_post_sale_question_type"
                  placeholder="请选择问题类型"
                />
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="问题状态">
                <j-dict-select-tag
                  v-model="queryParam.questionStatus"
                  dictCode="icm_post_sale_question_status"
                  placeholder="请选择问题状态"
                />
              </a-form-item>
            </a-col>
            <a-col :xl="12" :lg="7" :md="8" :sm="24">
              <a-form-item label="完成时间">
                <j-date
                  placeholder="请选择开始日期"
                  class="query-group-cust"
                  v-model="queryParam.completedDate_begin"
                ></j-date>
                <span class="query-group-split-cust"></span>
                <j-date
                  placeholder="请选择结束日期"
                  class="query-group-cust"
                  v-model="queryParam.completedDate_end"
                ></j-date>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button
        type="primary"
        icon="download"
        @click="handleExportXls('问题明细')"
        v-has="'PostSaleQuestionItem:export'"
        >导出</a-button
      >
    </div>
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
        <template slot="customerShortName" slot-scope="text, record">
          <a @click="handleDetail(record)">{{ text }}</a>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="clickOk(record)">完成</a>
        </span>
      </a-table>
    </div>
    <PostSaleQuestionItemModal ref="modalForm" @ok="modalFormOk"></PostSaleQuestionItemModal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import PostSaleQuestionItemModal from './modules/PostSaleQuestionItemModal'
import { initDictOptions, filterDictText } from '@/components/dict/JDictSelectUtil'

export default {
  name: 'PmProjectList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    PostSaleQuestionItemModal,
  },
  data() {
    return {
      description: '售后管理-问题明细页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '客户简称',
          align: 'center',
          dataIndex: 'customerShortName',
          scopedSlots: { customRender: 'customerShortName' },
        },
        {
          title: '项目名称',
          align: 'center',
          dataIndex: 'projectName',
        },
        {
          title: '项目经理',
          align: 'center',
          dataIndex: 'projectCharger',
        },
        {
          title: '期望完成日期',
          align: 'center',
          dataIndex: 'hopeDate',
        },
        {
          title: '问题类型',
          align: 'center',
          dataIndex: 'questionType',
          customRender: (text, record, index) => {
            return filterDictText(this.questionType_dictText, text)
          },
        },
        // {
        //   title: '问题描述',
        //   align: 'center',
        //   dataIndex: 'questionDesc',
        // },
        {
          title: '工时',
          align: 'center',
          dataIndex: 'workHours',
        },
        {
          title: '完成人',
          align: 'center',
          dataIndex: 'charger',
        },
        {
          title: '完成时间',
          align: 'center',
          dataIndex: 'completedDate',
        },
        {
          title: '问题状态',
          align: 'center',
          dataIndex: 'questionStatus',
          customRender: (text, record, index) => {
            return filterDictText(this.questionStatus_dictText, text)
          },
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/postsale/postSaleQuestionItem/list',
        exportXlsUrl: '/postsale/postSaleQuestionItem/exportXls',
      },
    }
  },
  created() {},
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    initDictConfig() {
      initDictOptions('icm_post_sale_question_status').then((res) => {
        if (res.success) {
          this.questionStatus_dictText = res.result
        }
      })
      initDictOptions('icm_post_sale_question_type').then((res) => {
        if (res.success) {
          this.questionType_dictText = res.result
        }
      })
    },
    clickOk(record) {
      this.$refs.modalForm.edit(record)
      this.$refs.modalForm.title = '完成'
      this.$refs.modalForm.disableSubmit = false
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
